//JavaScript Document
function validate()
{
	var flagCancel= false;
	if(document.questionnaire3.district[document.questionnaire3.district.selectedIndex].value==0)
	{
	  alert("Please Select District Name");
	  document.questionnaire3.district.focus();
	   return false;
	}
	if(document.questionnaire3.block[document.questionnaire3.block.selectedIndex].value==0)
	{
	  alert("Please Select Block Name");
	  document.questionnaire3.block.focus();
	   return false;
	}
	if(document.questionnaire3.tehsil[document.questionnaire3.tehsil.selectedIndex].value==0)
	{
	  alert("Please Select Tehsil Name");
	  document.questionnaire3.tehsil.focus();
	   return false;
	}
	if(document.questionnaire3.panchayat[document.questionnaire3.panchayat.selectedIndex].value==0)
	{
	  alert("Please Select Gram Panchayat Name");
	  document.questionnaire3.panchayat.focus();
	   return false;
	}
	if(document.questionnaire3.village[document.questionnaire3.village.selectedIndex].value==0)
	{
	  alert("Please Select Village Name");
	  document.questionnaire3.village.focus();
	   return false;
	}
	 if(document.questionnaire3.steam[document.questionnaire3.steam.selectedIndex].value==0)
	{
	  alert("Please Select Survey Team Name");
	  document.questionnaire3.steam.focus();
	   return false;
	}
	if(c1.checked && document.getElementById('file').value=="")
	{
		alert('Please Select Kml File');
		document.getElementById('file').focus();
		return false;
	}
	if(c1.checked && document.getElementById('file').value!="")
	{
		var fup = document.getElementById('file');
		var fileName = fup.value;
		var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
		if(ext == "kml" || ext == "kmz")
		{
		}
		else
		{
			alert("Upload KML file only");
			fup.focus();
			return false;
		}
	}
	if(!c1.checked)
	{
		var r=confirm('You have no Kml File for Uploading, If you want to upload then click OK otherwise click Cancel');
		if(r==true)
		{
		document.getElementById('c1').focus();
		return false;
		}
	}
	
   var counthabit=document.getElementById('habcount').value;
	for(var i=1;i<=counthabit;i++)
	{
		if(!c1.checked)
		{
			if(document.getElementById('longitude'+i).value=="" && document.getElementById('status'+i).value=="Existing")
			{
				alert('Please Enter Longitude Field'+i);
				document.getElementById('longitude'+i).focus();
				return false;
			}
			if(document.getElementById('latitude'+i).value=="" && document.getElementById('status'+i).value=="Existing")
			{
				alert('Please Enter Latitude Field'+i);
				document.getElementById('latitude'+i).focus();
				return false;
			}
		}
		
		if(document.getElementById('household'+i).value=="")
		{
			alert('Please Enter Household Field'+i);
			document.getElementById('household'+i).focus();
			return false;
		}
	}
	
	if(document.getElementById('num_habit').value>0)
	{
	var countunhab=document.getElementById('counthabit').value;
	for(var i=1;i<=countunhab;i++)
	{
		if(document.getElementById('un_habit'+i).value=="")
		{
			alert('Please Enter Value in Unlisted Habitation Name Field'+i);
			document.getElementById('un_habit'+i).focus();
			return false;
		}
		//if(!c1.checked && document.getElementById('num_habit').value!="")
		if(!c1.checked)
		{
				if(document.getElementById('un_longitude'+i).value=="")
				{
					alert('Please Enter Value in Unlisted Longitude Field'+i);
					document.getElementById('un_longitude'+i).focus();
					return false;
				}
				if(document.getElementById('un_latitude'+i).value=="")
				{
					alert('Please Enter Value in Unlisted Latitude Field'+i);
					document.getElementById('un_latitude'+i).focus();
					return false;
				}
		}
	}
	}
		
   if(!document.questionnaire3.cpo.checked && !document.questionnaire3.psd.checked && !document.questionnaire3.sds.checked && !document.questionnaire3.gs.checked && !document.questionnaire3.patwari.checked && !document.questionnaire3.hms.checked && !document.questionnaire3.phed.checked)
    {
    	alert('Please Check at Least One Key Person');
		return false;
    }
	else
	{
		if(document.questionnaire3.cpo.checked && document.questionnaire3.person_name1.value=="")
		{
			alert('Please Enter PHED Officer');
			document.questionnaire3.person_name1.focus();
			return false;
		}
		if(document.questionnaire3.psd.checked && document.questionnaire3.person_name2.value=="")
		{
			alert('Please Enter PHED Sub- Division');
			document.questionnaire3.person_name2.focus();
			return false;
		}
		if(document.questionnaire3.sds.checked && document.questionnaire3.person_name3.value=="")
		{
			alert('Please Enter Sarpanch/Dy. Sarpanch');
			document.questionnaire3.person_name3.focus();
			return false;
		}
		if(document.questionnaire3.gs.checked && document.questionnaire3.person_name4.value=="")
		{
			alert('Please Enter Gram Sewak');
			document.questionnaire3.person_name4.focus();
			return false;
		}
		if(document.questionnaire3.patwari.checked && document.questionnaire3.person_name5.value=="")
		{
			alert('Please Enter Patwari');
			document.questionnaire3.person_name5.focus();
			return false;
		}
		if(document.questionnaire3.hms.checked && document.questionnaire3.person_name6.value=="")
		{
			alert('Please Enter Head Master, Govt. School');
			document.questionnaire3.person_name6.focus();
			return false;
		}
		if(document.questionnaire3.phed.checked && document.questionnaire3.person_name7.value=="")
		{
			alert('Please Enter PHED Operator/Staff');
			document.questionnaire3.person_name7.focus();
			return false;
		}
	}
	
	return true; 
}

function view_validate()
{
	var flagCancel= false;
	if(document.view_main.district[document.view_main.district.selectedIndex].value==0)
	{
	  alert("Please Select District Name");
	  document.view_main.district.focus();
	   return false;
	}
	if(document.view_main.form_id[document.view_main.form_id.selectedIndex].value==0)
	{
	  alert("Please Select Form Id");
	  document.view_main.form_id.focus();
	   return false;
	}
}

function alphabet(field)
{
	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++)
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no")
	{
		alert("Invalid entry! Only Alphabetic Characters are Accepted!");
		//field.focus();
		field.select();
		return false;
   }

}


function numeric(field)
{
	var valid = "0123456789"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++)
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no")
	{
		alert("Invalid entry! Only Numeric Characters are Accepted!");
		//field.focus();
		field.value="";
		field.select();
		return false;
   }

}



/*function float1(field)
{
	var valid = "0123456789."
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++)
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no")
	{
		alert("Invalid entry! Only Numeric and Decimal Numbers are Accepted!");
		field.value="";
		field.select();
		return false;
   }
   var val=field.value;
   var arr=val.split(".");
   //alert(arr);
   if(field.value!="" && arr.length!=3)
   {
   		alert('Invalid Entry!Please Check Data');
		field.value="";
		field.select();
		return false
   }
}*/

/*function float1(field)
{
	var mystring = field.value;
	if(mystring != "")
	{
		if (!(mystring.match(/^\d*\.\d*$/)))
		{
			alert("Invalid entry! Enter Only Decimal Values (eg 67.3456)");
			//field.focus();
			field.value="";
			field.focus();
			return false;
		}
	}
	else
	{
		return true;
	}
}*/

function float1(field,mini,maxi)
{
			
	var value1 = field.value;
	var arr=value1.split(".");
	if(arr[0].length>2)
	{
		alert("Invalid entry! Enter Only Two Digit before Decimal");
		field.value="";
		field.focus();
		return false;
	}
	if(value1 != "")
	{
		if (!(value1.match(/^\d*\.\d*$/)))
		{
			alert("Invalid entry! Enter Only Decimal Values (eg "+mini+".12345)");
			//field.focus();
			field.value="";
			field.focus();
			return false;
		}
	}
	
	if(value1.indexOf(".") != -1)
	{
		if(!/\.[0-9]{5}$/.test(value1))
		{
			alert("Invalid entry! Enter Only Five Digit after Decimal (eg "+mini+".12345)");
			field.value="";
			field.focus();
			return false;
		}
	}
	if(field.value<mini || field.value>maxi)
    {
		alert('Please Enter Value before Decimal in Between '+mini+'-'+maxi);
		field.value="";
		field.select();
		return false;
	}

return true;
}


function float(field)
{
	
	var val = field.value;
	if(isNaN(val))
	{
		alert("Invalid entry! Only Integer and Float Values are Accepted!");
		field.value="";
		field.focus();
		return false;
	}
}

function add(obj)
{

	a1=Number(document.getElementById('quant_boundary'+obj).value);
	a2=Number(document.getElementById('present_population'+obj).value);
	//a3=Number(document.getElementById('population_other'+obj).value);
	a3=(a1 * 1000) / a2;
	var a4 = Math.round(a3*Math.pow(10,2))/Math.pow(10,2);
	//alert(a4);
	document.getElementById('per_capita'+obj).value=a4;
	//document.getElementById('population_total'+obj).disabled=false;
}

function add2(obj)
{

	a1=document.getElementById('house_connection_qty'+obj).value;
	a1=Number(a1);
	a2=document.getElementById('handpump_qty'+obj).value;
	a2=Number(a2);
	a3=document.getElementById('common_tap_qty'+obj).value;
	a3=Number(a3);
	a4=document.getElementById('tradi_source_qty'+obj).value;
	a4=Number(a4);
	a5=document.getElementById('tankers_qty'+obj).value;
	a5=Number(a5);
	a6=(a1+a2+a3+a4+a5);
	document.getElementById('water_received_household'+obj).value=a6;
	//document.getElementById('population_total'+obj).disabled=false;
}

function blank(a) 
{ 
	if(a.value == a.defaultValue) a.value = ""; 
}
function unblank(a) 
{
	if(a.value == "") a.value = a.defaultValue; 
}

function check_status1(status)
{
	if(document.getElementById('check_value').value=="kml_file")
	{
		var countloc=document.getElementById('loccount').value;
		for(var i=1; i<=countloc; i++)
		{
  		document.getElementById('longitude'+i).disabled=status;
  		document.getElementById('latitude'+i).disabled=status;
		}
	}
}
function enable_text(status)
{
  status=!status;
  document.questionnaire3.person_name1.disabled=status;
  document.questionnaire3.person_name2.disabled=status;
  document.questionnaire3.person_name3.disabled=status;
  document.questionnaire3.person_name4.disabled=status;
  document.questionnaire3.person_name5.disabled=status;
  document.questionnaire3.person_name6.disabled=status;
  document.questionnaire3.person_name7.disabled=status;
  
}
function enable_text1(status)
{
  status=!status;
  document.questionnaire3.person_name1.disabled=status;
  document.getElementById('person_name1').focus();
}
function enable_text2(status)
{
  status=!status;
  document.questionnaire3.person_name2.disabled=status;
  document.getElementById('person_name2').focus();
}
function enable_text3(status)
{
  status=!status;
  document.questionnaire3.person_name3.disabled=status;
  document.getElementById('person_name3').focus();
}
function enable_text4(status)
{
  status=!status;
  document.questionnaire3.person_name4.disabled=status;
  document.getElementById('person_name4').focus();
}
function enable_text5(status)
{
  status=!status;
  document.questionnaire3.person_name5.disabled=status;
  document.getElementById('person_name5').focus();
}
function enable_text6(status)
{
  status=!status;
  document.questionnaire3.person_name6.disabled=status;
  document.getElementById('person_name6').focus();
}

function enable_text7(status)
{
  status=!status;
  document.questionnaire3.person_name7.disabled=status;
  document.getElementById('person_name7').focus();
}


function setReadOnly(valobj,obj)
{
		
		if(!c1.checked)
		{
		document.getElementById('longitude'+obj).disabled=true;
		document.getElementById('latitude'+obj).disabled=true;
		}
		
		document.getElementById('household'+obj).disabled=true;
		document.getElementById('population_sc'+obj).disabled=true;
		document.getElementById('population_st'+obj).disabled=true;
		document.getElementById('population_other'+obj).disabled=true;
		document.getElementById('population_total'+obj).disabled=true;
		document.getElementById('status'+obj).value="NON TRACABLE"; 
		//alert(document.getElementById('status'+obj).value);
		/*if(!c1.checked && document.getElementById('status'+obj).checked)
		{
		document.getElementById('longitude'+obj).disabled=true;
		document.getElementById('latitude'+obj).disabled=true;
		}*/
		
}
function setEnable(valobj,obj)
{
		if(!c1.checked)
		{
		document.getElementById('longitude'+obj).disabled=false;
		document.getElementById('latitude'+obj).disabled=false;
		}
		
		document.getElementById('household'+obj).disabled=false;
		document.getElementById('population_sc'+obj).disabled=false;
		document.getElementById('population_st'+obj).disabled=false;
		document.getElementById('population_other'+obj).disabled=false;
		document.getElementById('population_total'+obj).disabled=false;
		document.getElementById('status'+obj).value="Existing";
	
}

function validate2()
{
   var counthouse=document.getElementById('housecount').value;
   for(var j=1;j<=counthouse;j++)
   { 
	}
}


function validate3()
{
   var pumpcount=document.getElementById('handpumpcount').value;
   for(var k=1;k<pumpcount;k++)
   {
	}
    
}

function numeric1(field)
{
    var valid = "0123456789"
    var ok = "yes";
    var temp;
    for (var i=0; i<field.value.length; i++) {
    temp = "" + field.value.substring(i, i+1);
    if (valid.indexOf(temp) == "-1") ok = "no";
    }
    if (ok == "no") {
    alert("Invalid entry! Only Numeric Characters are Accepted!");
    field.value="";
    field.select();
    return false;
    }
	if(field.value<1 || field.value>12)
    {
		alert('Please Enter 1-12 No.');
		field.value="";
		//document.getElementById('months_water_retained_bawaries').select();
		field.select();
		return false;
	}
}


function numeric2(field)
{
    
	var valid = "0123456789"
    var ok = "yes";
    var temp;
    for (var i=0; i<field.value.length; i++) {
    temp = "" + field.value.substring(i, i+1);
    if (valid.indexOf(temp) == "-1") ok = "no";
    }
    if (ok == "no") {
    alert("Invalid entry! Only Numeric Characters are Accepted!");
	field.value="";
    //field.focus();
    field.select();
    return false;
    }
	if(field.value<1 || field.value>11)
    {
		alert('Please Enter 1-11 No.');
		field.value="";
		field.select();
		return false;
	}
}

function validate6()
{
	if(document.getElementById('baw_no').value=="")
   {
      alert('Please Enter Numbers of Bawaries Field. If You Have No Data Fill 0');
	  document.getElementById('baw_no').focus();
	  return false;
   }
   if(document.getElementById('baw_no').value>0)
	{
		var countbaw=document.getElementById('countbaw').value;
		for(var m=1;m<=countbaw;m++)
		{
			if(document.getElementById('baw_location'+m).value=="")
			{
			   alert('Please Enter Bawaries Location Field'+m);
			   document.getElementById('baw_location'+m).select();
			   return false;
			}
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('baw_longitude'+m).value=="")
				{
					alert('Please Enter Bawaries Longitude Field'+m);
					document.getElementById('baw_longitude'+m).focus();
					return false;
				
				}
				if(document.getElementById('baw_latitude'+m).value=="")
				{
					alert('Please Enter Bawaries Latitude Field'+m);
					document.getElementById('baw_latitude'+m).focus();
					return false;
				
				}
			}
			
			
			if(document.getElementById('baw_approx_cap'+m).value=="")
			{
			   alert('Please Enter Bawaries Approaximate Capacity'+m);
			   document.getElementById('baw_approx_cap'+m).select();
			   return false;
			}
		}
	}
   
   
   if(document.getElementById('well_no').value=="")
   {
      alert('Please Enter Numbers of Old Open Well Field. If You Have No Data Fill 0');
	  document.getElementById('well_no').focus();
	  return false;
   }
   if(document.getElementById('well_no').value>0)
	{
		var countwell=document.getElementById('countwell').value;
		for(var m=1;m<=countwell;m++)
		{
			if(document.getElementById('well_location'+m).value=="")
			{
			   alert('Please Enter Old Open Well Location Field'+m);
			   document.getElementById('well_location'+m).select();
			   return false;
			}	
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('well_longitude'+m).value=="")
				{
					alert('Please Enter Old Open Well Longitude Field'+m);
					document.getElementById('well_longitude'+m).focus();
					return false;
				
				}
				if(document.getElementById('well_latitude'+m).value=="")
				{
					alert('Please Enter Old Open Well Latitude Field'+m);
					document.getElementById('well_latitude'+m).focus();
					return false;
				
				}
			}
			
			if(document.getElementById('well_approx_cap'+m).value=="")
			{
			   alert('Please Enter Old Open Well Approaximate Capacity'+m);
			   document.getElementById('well_approx_cap'+m).select();
			   return false;
			}
		}
	}
	
	if(document.getElementById('tanka_no').value=="")
   {
      alert('Please Enter Numbers of Public Tankas Field. If You Have No Data Fill 0');
	  document.getElementById('tanka_no').focus();
	  return false;
   }
   if(document.getElementById('tanka_no').value>0)
	{
		var counttanka=document.getElementById('counttanka').value;
		for(var m=1;m<=counttanka;m++)
		{
			if(document.getElementById('tanka_location'+m).value=="")
			{
			   alert('Please Enter Public Tankas Location Field'+m);
			   document.getElementById('tanka_location'+m).select();
			   return false;
			}	
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('tanka_longitude'+m).value=="")
				{
					alert('Please Enter Public Tankas Longitude Field'+m);
					document.getElementById('tanka_longitude'+m).focus();
					return false;
				
				}
				if(document.getElementById('tanka_latitude'+m).value=="")
				{
					alert('Please Enter Public Tankas Latitude Field'+m);
					document.getElementById('tanka_latitude'+m).focus();
					return false;
				
				}
			}
			
			if(document.getElementById('tanka_approx_cap'+m).value=="")
			{
			   alert('Please Enter Public Tankas Approaximate Capacity'+m);
			   document.getElementById('tanka_approx_cap'+m).select();
			   return false;
			}
		}
	}
	
	if(document.getElementById('house_tanka_no').value=="")
   {
      alert('Please Enter Numbers of House Hold Tankas Field. If You Have No Data Fill 0');
	  document.getElementById('house_tanka_no').focus();
	  return false;
   }
   if(document.getElementById('house_tanka_no').value>0)
	{
		var counthtanka=document.getElementById('counthtanka').value;
		for(var m=1;m<=counthtanka;m++)
		{
			if(document.getElementById('htanka_location'+m).value=="")
			{
			   alert('Please Enter House Hold Location Field'+m);
			   document.getElementById('htanka_location'+m).select();
			   return false;
			}	
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('htanka_longitude'+m).value=="")
				{
					alert('Please Enter House Hold Tankas Longitude Field'+m);
					document.getElementById('htanka_longitude'+m).focus();
					return false;
				
				}
				if(document.getElementById('htanka_latitude'+m).value=="")
				{
					alert('Please Enter House Hold Tankas Latitude Field'+m);
					document.getElementById('htanka_latitude'+m).focus();
					return false;
				
				}
			}
			
			if(document.getElementById('htanka_approx_cap'+m).value=="")
			{
			   alert('Please Enter House Hold Approaximate Capacity'+m);
			   document.getElementById('htanka_approx_cap'+m).select();
			   return false;
			}
		}
	}
	
	
	if(document.getElementById('pucca_no').value=="")
   {
      alert('Please Enter Numbers of Ponds Pucca Field. If You Have No Data Fill 0');
	  document.getElementById('pucca_no').focus();
	  return false;
   }
   if(document.getElementById('pucca_no').value>0)
	{
		var countpucca=document.getElementById('countpucca').value;
		for(var m=1;m<=countpucca;m++)
		{
			if(document.getElementById('pucca_location'+m).value=="")
			{
			   alert('Please Enter Ponds Pucca Location Field'+m);
			   document.getElementById('pucca_location'+m).select();
			   return false;
			}
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('pucca_longitude'+m).value=="")
				{
					alert('Please Enter Ponds Pucca Longitude Field'+m);
					document.getElementById('pucca_longitude'+m).focus();
					return false;
				
				}
				if(document.getElementById('pucca_latitude'+m).value=="")
				{
					alert('Please Enter Ponds Pucca Latitude Field'+m);
					document.getElementById('pucca_latitude'+m).focus();
					return false;
				
				}
			}
			
			if(document.getElementById('pucca_approx_cap'+m).value=="")
			{
			   alert('Please Enter Ponds Pucca Approaximate Capacity'+m);
			   document.getElementById('pucca_approx_cap'+m).select();
			   return false;
			}
		}
	}
	
	
	if(document.getElementById('kachha_no').value=="")
   {
      alert('Please Enter Numbers of Ponds Kachha Field. If You Have No Data Fill 0');
	  document.getElementById('kachha_no').focus();
	  return false;
   }
   if(document.getElementById('kachha_no').value>0)
	{
		var countkachha=document.getElementById('countkachha').value;
		for(var m=1;m<=countkachha;m++)
		{
			if(document.getElementById('kachha_location'+m).value=="")
			{
			   alert('Please Enter Ponds Kachha Location Field'+m);
			   document.getElementById('kachha_location'+m).select();
			   return false;
			}	
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('kachha_longitude'+m).value=="")
				{
					alert('Please Enter Ponds Kachha Longitude Field'+m);
					document.getElementById('kachha_longitude'+m).focus();
					return false;
				
				}
				if(document.getElementById('kachha_latitude'+m).value=="")
				{
					alert('Please Enter Ponds Kachha Latitude Field'+m);
					document.getElementById('kachha_latitude'+m).focus();
					return false;
				
				}
			}
			
			if(document.getElementById('kachha_approx_cap'+m).value=="")
			{
			   alert('Please Enter Ponds Kachha Approaximate Capacity'+m);
			   document.getElementById('kachha_approx_cap'+m).select();
			   return false;
			}
		}
	}
	
	if(document.getElementById('canal_no').value=="")
   {
      alert('Please Enter Numbers of Canal Water Ponds Field. If You Have No Data Fill 0');
	  document.getElementById('canal_no').focus();
	  return false;
   }
   if(document.getElementById('canal_no').value>0)
	{
		var countcanal=document.getElementById('countcanal').value;
		for(var m=1;m<=countcanal;m++)
		{
			if(document.getElementById('canal_location'+m).value=="")
			{
			   alert('Please Enter Canal Water Ponds Location Field'+m);
			   document.getElementById('canal_location'+m).select();
			   return false;
			}
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('canal_longitude'+m).value=="")
				{
					alert('Please Enter Canal Water Ponds Longitude Field'+m);
					document.getElementById('canal_longitude'+m).focus();
					return false;
				
				}
				if(document.getElementById('canal_latitude'+m).value=="")
				{
					alert('Please Enter Canal Water Ponds Latitude Field'+m);
					document.getElementById('canal_latitude'+m).focus();
					return false;
				
				}
			}
			
			
			if(document.getElementById('canal_approx_cap'+m).value=="")
			{
			   alert('Please Enter Canal Water Ponds Approaximate Capacity'+m);
			   document.getElementById('canal_approx_cap'+m).select();
			   return false;
			}
		}
	}
   return true;

}

function validate5()
{
    
	if(document.getElementById('num_glrs').value=="")
	{
	   alert('Please Enter GLRS Field');
	   document.getElementById('num_glrs').select();
	   return false;
	}
	
	
	if(document.getElementById('num_glrs').value>0)
	{
		var glrscount=document.getElementById('countglrs').value;
		for(var m=1;m<=glrscount;m++)
		{
			if(document.getElementById('glrs_location'+m).value=="")
			{
			   alert('Please Enter GLR Location Field'+m);
			   document.getElementById('glrs_location'+m).select();
			   return false;
			}	
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('glrs_longitude'+m).value=="")
				{
					alert('Please Enter GLR Longitude Field'+m);
					document.getElementById('glrs_longitude'+m).focus();
					return false;
				
				}
				if(document.getElementById('glrs_latitude'+m).value=="")
				{
					alert('Please Enter GLR Latitude Field'+m);
					document.getElementById('glrs_latitude'+m).focus();
					return false;
				
				}
			}
			if(document.getElementById('glrs_capacity'+m).value=="")
			{
			   alert('Please Enter GLR Capacity Field'+m);
			   document.getElementById('glrs_capacity'+m).select();
			   return false;
			}
		}
	}
	
	if(document.getElementById('num_glsr').value=="")
	{
	   alert('Please Enter GLSR Field');
	   document.getElementById('num_glsr').select();
	   return false;
	}
	
	if(document.getElementById('num_glsr').value>0)
	{
		var countglsr=document.getElementById('countglsr').value;
		
		for(var n=1;n<=countglsr;n++)
		{
			if(document.getElementById('glsr_location'+n).value=="")
			{
			   alert('Please Enter GLSR Location Field'+n);
			   document.getElementById('glsr_location'+n).select();
			   return false;
			}
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('glsr_longitude'+n).value=="")
				{
					alert('Please Enter GLSR Longitude Field'+n);
					document.getElementById('glsr_longitude'+n).focus();
					return false;
				
				}
				if(document.getElementById('glsr_latitude'+n).value=="")
				{
					alert('Please Enter GLSR Latitude Field'+n);
					document.getElementById('glsr_latitude'+n).focus();
					return false;
				
				}
			}
			
			if(document.getElementById('glsr_capacity'+n).value=="")
			{
			   alert('Please Enter GLSR Capacity Field'+n);
			   document.getElementById('glsr_capacity'+n).select();
			   return false;
			}
		}
	}
		
}


function validate7()
{
    if(document.getElementById('total_sub_pump').value=="")
	{
	   alert('Please Enter Submersible Pump in Total Field. If You Have No Data Fill 0');
	   document.getElementById('total_sub_pump').focus();
	   return false;
	}
	if(document.getElementById('total_sub_pump').value>0)
	{
		var submcount=document.getElementById('submcount').value;
		
		for(var n=1;n<=submcount;n++)
		{
			if(document.getElementById('sub_location'+n).value=="")
			{
			   alert('Please Enter Submersible Location Field'+n);
			   document.getElementById('sub_location'+n).select();
			   return false;
			}
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('sub_longitude'+n).value=="")
				{
					alert('Please Enter Submersible Longitude Field'+n);
					document.getElementById('sub_longitude'+n).focus();
					return false;
				
				}
				if(document.getElementById('sub_latitude'+n).value=="")
				{
					alert('Please Enter Submersible Latitude Field'+n);
					document.getElementById('sub_latitude'+n).focus();
					return false;
				
				}
			}
			
		}
	}
	if(document.getElementById('total_mono_block_pump').value=="")
	{
	   alert('Please Enter Mono- Block Pump in Total Field. If You Have No Data Fill 0');
	   document.getElementById('total_mono_block_pump').focus();
	   return false;
	}
	if(document.getElementById('total_mono_block_pump').value>0)
	{
		var monocount=document.getElementById('monocount').value;
		
		for(var n=1;n<=monocount;n++)
		{
			if(document.getElementById('mono_location'+n).value=="")
			{
			   alert('Please Enter Mono - Block Pump Location Field'+n);
			   document.getElementById('mono_location'+n).select();
			   return false;
			}
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('mono_longitude'+n).value=="")
				{
					alert('Please Enter Mono - Block Pump Longitude Field'+n);
					document.getElementById('mono_longitude'+n).focus();
					return false;
				
				}
				if(document.getElementById('mono_latitude'+n).value=="")
				{
					alert('Please Enter Mono - Block Pump Latitude Field'+n);
					document.getElementById('mono_latitude'+n).focus();
					return false;
				
				}
			}
			
			
		}
	}
	if(document.getElementById('total_centrifugal_pump').value=="")
	{
	   alert('Please Enter Centrifugal Pump in Total Field.If You Have No Data Fill 0');
	   document.getElementById('total_centrifugal_pump').focus();
	   return false;
	}
	if(document.getElementById('total_centrifugal_pump').value>0)
	{
		var centicount=document.getElementById('centicount').value;
		
		for(var n=1;n<=centicount;n++)
		{
			if(document.getElementById('centi_location'+n).value=="")
			{
			   alert('Please Enter Centrifugal Pump Location Field'+n);
			   document.getElementById('centi_location'+n).select();
			   return false;
			}
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('centi_longitude'+n).value=="")
				{
					alert('Please Enter Centrifugal Pump Longitude Field'+n);
					document.getElementById('centi_longitude'+n).focus();
					return false;
				
				}
				if(document.getElementById('centi_latitude'+n).value=="")
				{
					alert('Please Enter Centrifugal Pump Latitude Field'+n);
					document.getElementById('centi_latitude'+n).focus();
					return false;
				
				}
			}
		}
	}
	if(document.getElementById('total_single_phase_pump').value=="")
	{
	   alert('Please Enter Single Phase Pump in Total Field. If You Have No Data Fill 0');
	   document.getElementById('total_single_phase_pump').focus();
	   return false;
	}
	
	if(document.getElementById('total_single_phase_pump').value>0)
	{
		var spcount=document.getElementById('spcount').value;
		
		for(var n=1;n<=spcount;n++)
		{
			if(document.getElementById('sp_location'+n).value=="")
			{
			   alert('Please Enter Single Phase Pump Location Field'+n);
			   document.getElementById('sp_location'+n).select();
			   return false;
			}
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('sp_longitude'+n).value=="")
				{
					alert('Please Enter Single Phase Pump Longitude Field'+n);
					document.getElementById('sp_longitude'+n).focus();
					return false;
				
				}
				if(document.getElementById('sp_latitude'+n).value=="")
				{
					alert('Please Enter Single Phase Pump Latitude Field'+n);
					document.getElementById('sp_latitude'+n).focus();
					return false;
				
				}
			}
			
			
		}
	}
	if(document.getElementById('num_cwr').value=="")
	{
	   alert('Please Enter CWR in Total No. Field. If You Have No Data Fill 0');
	   document.getElementById('num_cwr').focus();
	   return false;
	}
	if(document.getElementById('num_cwr').value>0)
	{
		var cwrcount=document.getElementById('cwrcount').value;
		
		for(var n=1;n<=cwrcount;n++)
		{
			if(document.getElementById('cwr_location'+n).value=="")
			{
			   alert('Please Enter CWR Location Field'+n);
			   document.getElementById('cwr_location'+n).select();
			   return false;
			}
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('cwr_longitude'+n).value=="")
				{
					alert('Please Enter CWR Longitude Field'+n);
					document.getElementById('cwr_longitude'+n).focus();
					return false;
				
				}
				if(document.getElementById('cwr_latitude'+n).value=="")
				{
					alert('Please Enter CWR Latitude Field'+n);
					document.getElementById('cwr_latitude'+n).focus();
					return false;
				
				}
			}
			
			if(document.getElementById('capacity_cwr'+n).value=="")
			{
			   alert('Please Enter CWR Capacity Field'+n);
			   document.getElementById('capacity_cwr'+n).select();
			   return false;
			}
		}
	}
	if(document.getElementById('num_cwr').value < document.getElementById('sc_st_cwr').value)
	  {
		  alert('Please Check!No. of SC/ST Basti Not Greater Than Total No. of CWR');
		  document.getElementById('sc_st_cwr').focus();
		  return false;
	  }
	  /*if(document.getElementById('num_glsr').value=="")
	{
	   alert('Please Enter GLSR in Total No. Field. If You Have No Data Fill 0');
	   document.getElementById('num_glsr').focus();
	   return false;
	}
	if(document.getElementById('num_glsr').value>0)
	{
		var glsrcount=document.getElementById('glsrcount').value;
		
		for(var n=1;n<=glsrcount;n++)
		{
			if(document.getElementById('glsr_location'+n).value=="")
			{
			   alert('Please Enter GLSR Location Field'+n);
			   document.getElementById('glsr_location'+n).select();
			   return false;
			}
			
			
			
			if(document.getElementById('capacity_glsr'+n).value=="")
			{
			   alert('Please Enter GLSR Capacity Field'+n);
			   document.getElementById('capacity_glsr'+n).select();
			   return false;
			}
		}
	}
	if(document.getElementById('num_glsr').value<document.getElementById('sc_st_glsr').value)
	  {
		  alert('Please Check!No. of SC/ST Basti Not Greater Than Total No. of GLSR');
		  document.getElementById('sc_st_glsr').focus();
		  return false;
	  }
	  if(document.getElementById('num_glr').value=="")
	{
	   alert('Please Enter GLR in Total No. Field. If You Have No Data Fill 0');
	   document.getElementById('num_glr').focus();
	   return false;
	}
	if(document.getElementById('num_glr').value>0)
	{
		var glrcount=document.getElementById('glrcount').value;
		
		for(var n=1;n<=glrcount;n++)
		{
			if(document.getElementById('glr_location'+n).value=="")
			{
			   alert('Please Enter GLR Location Field'+n);
			   document.getElementById('glr_location'+n).select();
			   return false;
			}
			if(document.getElementById('capacity_glr'+n).value=="")
			{
			   alert('Please Enter GLR Capacity Field'+n);
			   document.getElementById('capacity_glr'+n).select();
			   return false;
			}
		}
	}
	if(document.getElementById('num_glr').value<document.getElementById('sc_st_glr').value)
	  {
		  alert('Please Check!No. of SC/ST Basti Not Greater Than Total No. of GLR');
		  document.getElementById('sc_st_glr').focus();
		  return false;
	  }*/
	if(document.getElementById('num_ohsr').value=="")
	{
	   alert('Please Enter OHSR in Total No. Field. If You Have No Data Fill 0');
	   document.getElementById('num_ohsr').focus();
	   return false;
	}
	if(document.getElementById('num_ohsr').value>0)
	{
		var ohsrcount=document.getElementById('ohsrcount').value;
		
		for(var n=1;n<=ohsrcount;n++)
		{
			if(document.getElementById('ohsr_location'+n).value=="")
			{
			   alert('Please Enter OHSR Location Field'+n);
			   document.getElementById('ohsr_location'+n).select();
			   return false;
			}
			
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('ohsr_longitude'+n).value=="")
				{
					alert('Please Enter OHSR Longitude Field'+n);
					document.getElementById('ohsr_longitude'+n).focus();
					return false;
				
				}
				if(document.getElementById('ohsr_latitude'+n).value=="")
				{
					alert('Please Enter OHSR Latitude Field'+n);
					document.getElementById('ohsr_latitude'+n).focus();
					return false;
				
				}
			}
			
			if(document.getElementById('capacity_ohsr'+n).value=="")
			{
			   alert('Please Enter OHSR Capacity Field'+n);
			   document.getElementById('capacity_ohsr'+n).select();
			   return false;
			}
		}
	}
	if(document.getElementById('num_ohsr').value<document.getElementById('sc_st_ohsr').value)
	  {
		  alert('Please Check!No. of SC/ST Basti Not Greater Than Total No. of OHSR');
		  document.getElementById('sc_st_ohsr').focus();
		  return false;
	  }
	  if(document.getElementById('psp_total').value=="")
	{
	   alert('Please Enter PSP Total Field. If You Have No Data Fill 0');
	   document.getElementById('psp_total').focus();
	   return false;
	}
	if(document.getElementById('psp_total').value<document.getElementById('psp_sc_st').value)
	  {
		  alert('Please Check!No. of SC/ST Basti Not Greater Than Total No. of PSP');
		  document.getElementById('psp_sc_st').focus();
		  return false;
	  }
	  
	  if(document.getElementById('psp_total').value>0)
	{
		var pspcount=document.getElementById('pspcount').value;
		
		for(var n=1;n<=pspcount;n++)
		{
			if(document.getElementById('psp_taps'+n).value=="")
			{
			   alert('Please Enter PSP Taps/No. Field'+n);
			   document.getElementById('psp_taps'+n).select();
			   return false;
			}
						
			if(document.getElementById('psp_loc'+n).value=="")
			{
			   alert('Please Enter PSP Location Field'+n);
			   document.getElementById('psp_loc'+n).select();
			   return false;
			}
			if(document.getElementById('check_value').value=="")
			{
				if(document.getElementById('psp_longitude'+n).value=="")
				{
					alert('Please Enter PSP Longitude Field'+n);
					document.getElementById('psp_longitude'+n).focus();
					return false;
				
				}
				if(document.getElementById('psp_latitude'+n).value=="")
				{
					alert('Please Enter PSP Latitude Field'+n);
					document.getElementById('psp_latitude'+n).focus();
					return false;
				
				}
			}
			
			
		}
	}
}
function validate4()
{
	var countloc=document.getElementById('loccount').value;
	//alert(countloc);
	for(var p=1;p<=countloc;p++)
	{
		if((document.getElementById('source_type'+p).value).substring(0,4)!="Tank") 
		{
			//alert((document.getElementById('source_type'+p).value).substring(0,4));	
			if((document.getElementById('source_type'+p).value).substring(0,4)!="Cart")
			{
			//alert((document.getElementById('source_type'+p).value).substring(0,4));	
			if(document.getElementById('location'+p).value=="")
			{
	   			alert('Please Enter Location Field'+p);
	   			document.getElementById('location'+p).focus();
	  			return false;
			}
		
		if(document.getElementById('check_value').value=="")
		{					   
				if(document.getElementById('longitude'+p).value=="")
				{
					alert('Please Enter Longitude Field'+p);
					document.getElementById('longitude'+p).focus();
					return false;	
				}
				if(document.getElementById('latitude'+p).value=="")
				{
					alert('Please Enter Latitude Field'+p);
					document.getElementById('latitude'+p).focus();
					return false;	
				}
			//}
			
		}
		}
	}
		var rad=document.getElementById('function_status'+p);
		if(rad.checked)
		{
			if(document.getElementById('water_table_fluctuation_min'+p).value=="")
			{
				alert('Please Enter Water Table Fluctuation in Min Field'+p)
				document.getElementById('water_table_fluctuation_min'+p).focus();
				return false;
			}
			if(document.getElementById('water_table_fluctuation_max'+p).value=="")
			{
				alert('Please Enter Water Table Fluctuation in Max Field'+p)
				document.getElementById('water_table_fluctuation_max'+p).focus();
				return false;
			}
			
			if(Number(document.getElementById('water_table_fluctuation_min'+p).value) > Number(document.getElementById('water_table_fluctuation_max'+p).value))
			{
				//alert(document.getElementById('water_table_fluctuation_min'+p).value);
				alert('Water Table Fluctuation Minimum Value should be less than Water Table Fluctuation Maximum Value');
				document.getElementById('water_table_fluctuation_min'+p).focus();
				return false;
			}
	
		
		if(document.getElementById('para_ph'+p).value=="")
			{
				alert('Please Enter Parameters pH Field'+p)
				document.getElementById('para_ph'+p).focus();
				return false;
			}
		
		/*if(document.getElementById('para_ph'+p).value<6 || document.getElementById('para_ph'+p).value>10)
		{
	   		alert('Please Enter 6-10 Number of pH Field'+p);
	   		document.getElementById('para_ph'+p).focus();
	  		return false;
		}*/
		
		if(document.getElementById('para_tds'+p).value=="")
			{
				alert('Please Enter Parameters TDS Field'+p)
				document.getElementById('para_tds'+p).focus();
				return false;
			}
		/*if(document.getElementById('para_tds'+p).value<100 || document.getElementById('para_tds'+p).value>40000)
		{
	   		alert('Please Enter 100-40000 Number of TDS Field'+p);
	   		document.getElementById('para_tds'+p).focus();
	  		return false;
		}*/
		
		if(document.getElementById('para_cl'+p).value=="")
			{
				alert('Please Enter Parameters Cl Field'+p)
				document.getElementById('para_cl'+p).focus();
				return false;
			}
		/*if(document.getElementById('para_cl'+p).value<50 || document.getElementById('para_cl'+p).value>15000)
		{
	   		alert('Please Enter 50-15000 Number of Cl Field'+p);
	   		document.getElementById('para_cl'+p).focus();
	  		return false;
		}*/
		
		if(document.getElementById('para_f'+p).value=="")
			{
				alert('Please Enter Parameters F Field'+p)
				document.getElementById('para_f'+p).focus();
				return false;
			}
		/*if(document.getElementById('para_f'+p).value<0 || document.getElementById('para_cl'+p).value>18)
		{
	   		alert('Please Enter 0-18 Number of F Field'+p);
	   		document.getElementById('para_f'+p).focus();
	  		return false;
		}*/
		 if(document.getElementById('para_no'+p).value=="")
			{
				alert('Please Enter Parameters NO3 Field'+p)
				document.getElementById('para_no'+p).focus();
				return false;
			}
		}
		/*if(document.getElementById('para_no'+p).value<0 || document.getElementById('para_no'+p).value>2500)
		{
	   		alert('Please Enter 0-2500 Number of NO3 Field'+p);
	   		document.getElementById('para_no'+p).focus();
	  		return false;
		}*/	
			
			
			var rad=document.getElementById('function_status'+p);
	 		var rad1=document.getElementById('remarks'+p);
	 		//alert(rad.value);
		 var chks = document.getElementsByName('repairable_status'+p);
     	var hasChecked = false;
     	if(!rad.checked)
	 	{
	 		for (var i = 0; i < chks.length; i++)
     		{
     			if (chks[i].checked)
     			{
    				 hasChecked = true;
     				 break;
     			}
     		}
	 		if (hasChecked == false)
    		{
    			alert('Please Check at Least One in Repairable Status'+p);
    			return false;
    		}
		}
	}
    
}

/*function check(field)
{
 var val = field.value/1;
 // limit to 2 dec places (rounding up, if needed)
 field.value = Math.round(val*100)/100
 // check <7 after dec point
 if(!(val>1))
 {
 	alert("More than 6 figures after decimal point");
 }

}*/

function check(field,mini,maxi)
{
	var valid = "0123456789"
    var ok = "yes";
    var temp;
    for (var i=0; i<field.value.length; i++) {
    temp = "" + field.value.substring(i, i+1);
    if (valid.indexOf(temp) == "-1") ok = "no";
    }
    if (ok == "no") {
    alert("Invalid entry! Only Numeric Characters are Accepted!");
	field.value="";
    //field.focus();
    field.select();
    return false;
    }
	
	var value1 = field.value;
	if(value1.indexOf(".") != -1)
	{
		if(!/\.[0-9]{1,1}$/.test(value1))
		{
			alert("Number Should be One Digit after Decimal");
			field.value="";
			field.focus();
			return false;
		}
	}
	if(field.value<mini || field.value>maxi)
    {
		alert('Please Check Entered Value');
		field.value="";
		field.select();
		return false;
	}

return true;
}

function check1(field,mini,maxi)
{
	var valid = "0123456789."
    var ok = "yes";
    var temp;
    for (var i=0; i<field.value.length; i++) {
    temp = "" + field.value.substring(i, i+1);
    if (valid.indexOf(temp) == "-1") ok = "no";
    }
    if (ok == "no") {
    alert("Invalid entry! Only Numeric Characters are Accepted!");
	field.value="";
    //field.focus();
    field.select();
    return false;
    }
	
	var value1 = field.value;
	if(value1.indexOf(".") != -1)
	{
		if(!/\.[0-9]{1,1}$/.test(value1))
		{
			alert("Number Should be One Digit after Decimal");
			field.value="";
			field.focus();
			return false;
		}
	}
	if(field.value<mini || field.value>maxi)
    {
		alert('Please Check Entered Value');
		field.value="";
		field.select();
		return false;
	}

return true;
}




function createuser()
{
   if(document.getElementById('name').value=="")	
	{
		alert('Please Enter Name Field');
	    document.getElementById('name').focus();
		return false;
	}
    
	if(document.admin.usertype[document.admin.usertype.selectedIndex].value==0)
	{
	  alert("Please Select Usertype Field");
	  document.admin.usertype.focus();
	   return false;
	}
	
	if(document.getElementById('login_id').value=="")	
	{
		alert('Please Enter Loginid Field');
	    document.getElementById('login_id').focus();
		return false;
	}
	if(document.getElementById('password').value=="")	
	{
		alert('Please Enter Password Field');
	    document.getElementById('password').focus();
		return false;
	}
	if(document.getElementById('password').value.length<6 || document.getElementById('password').value.length>15)
	{
		alert('Please Enter Password Min 6 Charecter and Max 15 Charecter');
		document.getElementById('password').focus();
		return false;
		
	}
	
	if(document.getElementById('password').value!=document.getElementById('repeatpassword').value)	
	{
		alert('Please Check!Password and Repeat Password Must be Equal');
	    document.getElementById('repeatpassword').focus();
		return false;
	}
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.getElementById('emailid').value;
   if(reg.test(address) == false)
   {
      alert('Invalid Email Address');
	  document.getElementById('emailid').focus();
      return false;
   }
	

}

function edituser()
{
    if(document.getElementById('name').value=="")	
	{
		alert('Please Enter Name Field');
	    document.getElementById('name').focus();
		return false;
	}
	if(document.getElementById('loginid').value=="")	
	{
		alert('Please Enter Loginid Field');
	    document.getElementById('loginid').focus();
		return false;
	}
   
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.getElementById('emailid').value;
   if(reg.test(address) == false)
   {
      alert('Invalid Email Address');
	  document.getElementById('emailid').focus();
      return false;
   }
}


function changepass()
{
	if(document.getElementById('old_password').value=="")	
	{
		alert('Please Enter Old Password Field');
	    document.getElementById('old_password').focus();
		return false;
	}
	if(document.getElementById('new_password').value=="")	
	{
		alert('Please Enter New Password Field');
	    document.getElementById('new_password').focus();
		return false;
	}
	if(document.getElementById('new_password').value.length<6 || document.getElementById('new_password').value.length>15)
	{
		alert('Please Enter New Password Min 6 Charecter and Max 15 Charecter');
		document.getElementById('new_password').focus();
		return false;
		
	}
	
	if(document.getElementById('new_password').value!=document.getElementById('confirm_new_password').value)	
	{
		alert('Please Check!New Password and Confirm New Password Must be Equal');
	    document.getElementById('confirm_new_password').focus();
		return false;
	}
	
}

//Validation for Critical form by Shakil Ahmad

function float2dec(field)
{	
	var value1 = field.value;
	if(isNaN(value1))
	{
		alert("Invalid entry! Only integer and decimal values are accepted!");
		field.value="";
		field.focus();
		return false;
	}
	if(value1.indexOf(".") != -1)
	{
		if(!/\.[0-9]{2}$/.test(value1))
		{
			alert("Number should be two digit after decimal");
			field.value="";
			field.focus();
			return false;
		}
	}	
}

function critical()
{
	
		var a={'District':'district','Block':'block','Tehsil':'tehsil','Gram Panchayat':'panchayat','Village':'village'};
	 	for(var fields in a)
		{	
			var c = document.getElementsByName(a[fields]);  
          	for(var j = 0; j < c.length; j++)
         	{
		 	
		 		if(c[j].value == "")  
         		{  
            		alert('Please Select '+fields+' Name');
					c[j].focus();
					return false;       
         		}
		 	}
	 	}
		
		var countunlist=document.getElementById('cnt_habit').value;
		for(var i=1;i<countunlist;i++)
		{
			if(document.getElementById('un_habit_crit'+i).value=='')
			{
				alert('Please enter unlisted habitation name'+i);
				document.getElementById('un_habit_crit'+i).focus();
				return false;
			
			}
	
		}
		
		
		var a={'type_scheme':'type_scheme_other,other type of scheme','sources[]':'source_other,other type of source'};
	 	for(var fields in a)
		{	
			var arr=a[fields].split(",");
			var c = document.getElementsByName(arr[0]);  
          	var d = document.getElementsByName(fields);
			//alert(d[0]);
			if(fields=="type_scheme")
			{
			if(!d[0].checked && !d[1].checked && !d[2].checked && !d[3].checked && !d[4].checked) 
			{
				alert('Please select type of scheme');
				d[0].focus();
				return false;
			}
			}
			if(fields=="sources[]")
			{
			if(!d[0].checked && !d[1].checked && !d[2].checked && !d[3].checked) 
			{
				alert('Please Check Atleast One Source of Agriculture Purposes');
				d[0].focus();
				return false;
			}
			}
			for(var m=0;m<d.length;m++)
			{
				
				for(var j = 0; j < c.length; j++)
				{
				
					if(d[m].checked)
					{
					if(c[j].value == "" && d[m].value=="Other")  
					{  
						//alert(c[j].value);
						//alert(d[m].value);
						alert('Please enter the value in '+arr[1]+' field');
						c[j].focus();
						return false;
							
					 }
					}
				 }
			 }
		}
			if(!document.getElementById('tanker_cap4').checked && !document.getElementById('tanker_cap5').checked && !document.getElementById('tanker_cap10').checked && !document.getElementById('tanker_cap_other').checked) 
			{
				alert('Please Check Atleast One Type of Tanker');
				document.getElementById('tanker_cap4').focus();
				return false;
			}
		 if(document.getElementById('tanker_cap4').checked)
		 {
				//alert(document.getElementById('kl4_trips').value);
				if(document.getElementById('kl4_trips').value=="")
				{
					alert('Please enter the value 4kl no. of trips field');
					document.getElementById('kl4_trips').focus();
					return false;
				}
				var chks = document.getElementsByName('kl4_sources[]');
     			//var hasChecked = false;
     			if (!chks[0].checked && !chks[1].checked && !chks[2].checked)
    			{
    				alert('Please check at least one in 4kl type of source ');
    				return false;
    			}
				
				for (var i = 0; i < chks.length; i++)
     			{
     				if (chks[i].checked)
     				{
     					if(chks[i].value=="Other" && document.getElementById('kl4_source_other').value=="")
						{
							alert('Please enter the value other 4kl type of source');
							document.getElementById('kl4_source_other').focus();
							return false;
							
						}
						
     				}
     			}
	 			
				if(document.getElementById('kl4_tanker_distance').value=="")
				{
					alert('Please enter the value 4kl tanker of distance field');
					document.getElementById('kl4_tanker_distance').focus();
					return false;
				}
				if(document.getElementById('kl4_tanker_cost').value=="")
				{
					alert('Please enter the value 4kl tanker of cost field');
					document.getElementById('kl4_tanker_cost').focus();
					return false;
				}
			}
			
			
			//--------------------------------------------------------------------------------------------------
			
			if(document.getElementById('tanker_cap5').checked)
			{
				//alert(document.getElementById('kl4_trips').value);
				if(document.getElementById('kl5_trips').value=="")
				{
					alert('Please enter the value 5kl no. of trips field');
					document.getElementById('kl5_trips').focus();
					return false;
				}
				var chks = document.getElementsByName('kl5_sources[]');
     			//var hasChecked = false;
     			if (!chks[0].checked && !chks[1].checked && !chks[2].checked)
    			{
    				alert('Please check at least one in 5kl type of source ');
    				return false;
    			}
				
				for (var i = 0; i < chks.length; i++)
     			{
     				if (chks[i].checked)
     				{
     					if(chks[i].value=="Other" && document.getElementById('kl5_source_other').value=="")
						{
							alert('Please enter the value other 5kl type of source');
							document.getElementById('kl5_source_other').focus();
							return false;
							
						}
						
     				}
     			}
	 			
				if(document.getElementById('kl5_tanker_distance').value=="")
				{
					alert('Please enter the value 5kl tanker of distance field');
					document.getElementById('kl5_tanker_distance').focus();
					return false;
				}
				if(document.getElementById('kl5_tanker_cost').value=="")
				{
					alert('Please enter the value 5kl tanker of cost field');
					document.getElementById('kl5_tanker_cost').focus();
					return false;
				}
			}
			
			
			//--------------------------------------------------------------------------------
			
			if(document.getElementById('tanker_cap10').checked)
		{
				//alert(document.getElementById('kl4_trips').value);
				if(document.getElementById('kl10_trips').value=="")
				{
					alert('Please enter the value 10kl no. of trips field');
					document.getElementById('kl10_trips').focus();
					return false;
				}
				var chks = document.getElementsByName('kl10_sources[]');
     			//var hasChecked = false;
     			if (!chks[0].checked && !chks[1].checked && !chks[2].checked)
    			{
    				alert('Please check at least one in 10kl type of source ');
    				return false;
    			}
				
				for (var i = 0; i < chks.length; i++)
     			{
     				if (chks[i].checked)
     				{
     					if(chks[i].value=="Other" && document.getElementById('kl10_source_other').value=="")
						{
							alert('Please enter the value other 10kl type of source');
							document.getElementById('kl10_source_other').focus();
							return false;
							
						}
						
     				}
     			}
	 			
				if(document.getElementById('kl10_tanker_distance').value=="")
				{
					alert('Please enter the value 10kl tanker of distance field');
					document.getElementById('kl10_tanker_distance').focus();
					return false;
				}
				if(document.getElementById('kl10_tanker_cost').value=="")
				{
					alert('Please enter the value 10kl tanker of cost field');
					document.getElementById('kl10_tanker_cost').focus();
					return false;
				}
			}
			
			//---------------------------------------------------------------------------
			
			if(document.getElementById('tanker_cap_other').checked)
		{
				//alert(document.getElementById('kl4_trips').value);
				if(document.getElementById('other_cap').value=="")
				{
					alert('Please enter the value other capacity field');
					document.getElementById('other_cap').focus();
					return false;
				}
				
				if(document.getElementById('other_trips').value=="")
				{
					alert('Please enter the value other no. of trips field');
					document.getElementById('other_trips').focus();
					return false;
				}
				var chks = document.getElementsByName('other_sources[]');
     			//var hasChecked = false;
     			if (!chks[0].checked && !chks[1].checked && !chks[2].checked)
    			{
    				alert('Please check at least one in other type of source ');
    				return false;
    			}
				
				for (var i = 0; i < chks.length; i++)
     			{
     				if (chks[i].checked)
     				{
     					if(chks[i].value=="Other" && document.getElementById('text_source_other').value=="")
						{
							alert('Please enter the value other type of source');
							document.getElementById('text_source_other').focus();
							return false;
							
						}
						
     				}
     			}
	 			
				if(document.getElementById('other_tanker_distance').value=="")
				{
					alert('Please enter the value other tanker of distance field');
					document.getElementById('other_tanker_distance').focus();
					return false;
				}
				if(document.getElementById('other_tanker_cost').value=="")
				{
					alert('Please enter the value other tanker of cost field');
					document.getElementById('other_tanker_cost').focus();
					return false;
				}
			}
	
	
	
}

function multank4()
{
	var field=document.getElementById('kl4_trips').value;
	var c=4*field;
	document.getElementById('kl4_supply').value=c;

}

function multank5()
{
	var field=document.getElementById('kl5_trips').value;
	var c=5*field;
	document.getElementById('kl5_supply').value=c;

}

function multank10()
{
	var field=document.getElementById('kl10_trips').value;
	var c=10*field;
	document.getElementById('kl10_supply').value=c;

}

function multankother()
{
	var field=document.getElementById('other_trips').value;
	var d=document.getElementById('other_cap').value;
	var c=d*field;
	document.getElementById('other_supply').value=c;

}

function CritDisable(status)
{

  status=!status;
  document.getElementById('type_scheme_other').disabled=status;
  document.getElementById('source_other').disabled=status;
  document.getElementById('kl4_source_other').disabled=status;
  document.getElementById('kl5_source_other').disabled=status;
  document.getElementById('kl10_source_other').disabled=status;
  document.getElementById('text_source_other').disabled=status;
  
}

function CritEnabScheme(status)
{

  status=!status;
  document.getElementById('type_scheme_other').disabled=status;
  document.getElementById('type_scheme_other').focus();
  //document.getElementById('type_scheme').value="Other";
}
	
function CritEnabSource(status)
{

  status=!status;
  document.getElementById('source_other').disabled=status;
  document.getElementById('source_other').focus();
}

function CritEnab4Source(status)
{

  status=!status;
  document.getElementById('kl4_source_other').disabled=status;
  document.getElementById('kl4_source_other').focus();
}
function CritEnab5Source(status)
{

  status=!status;
  document.getElementById('kl5_source_other').disabled=status;
  document.getElementById('kl5_source_other').focus();
}

function CritEnab10Source(status)
{
  status=!status;
  document.getElementById('kl10_source_other').disabled=status;
  document.getElementById('kl10_source_other').focus();
}

function CritEnabOtherSource(status)
{
  status=!status;
  document.getElementById('text_source_other').disabled=status;
  document.getElementById('text_source_other').focus();
}

function total_pot_hp()
{
	if(Number(document.getElementById('hp_potable').value) > Number(document.getElementById('hp_total').value))
	{
		//alert(document.getElementById('hp_potable').value);
		//alert(document.getElementById('hp_total').value);		
		alert('HP Potable num should be less than HP Total num');
		document.getElementById('hp_potable').value="";
		//document.getElementById('hp_potable').focus();
		return false;
	}
}
function total_pot_tw()
{
	if(Number(document.getElementById('tw_potable').value) > Number(document.getElementById('tw_total').value))
	{
		//alert(document.getElementById('tw_potable').value);
		//alert(document.getElementById('tw_total').value);		
		alert('TW Potable num should be less than TW Total num');
		document.getElementById('tw_potable').value="";
		//document.getElementById('hp_potable').focus();
		return false;
	}
}



//===========================UFW========UFW=======UFW===========UFW=============================================

function ufw1()
{
var a={'name of RWSS':'rwss_name','name of servey team leader':'team_leader','no. of source villages':'num_src_village'};
	 	for(var fields in a)
		{	
			var c = document.getElementsByName(a[fields]);  
          	
			for(var j = 0; j < c.length; j++)
         	{
		 	
		 		if(c[j].value == "" || c[j].value == 0)  
         		{  
            		
					alert('Please enter '+fields+' field');
					c[j].focus();
					return false;       
         		}
		 	}
	 	}
		
		/*var a={'district name':'district_name','block name':'block_name','gram panchayat name':'panchayat_name','village name':'village_name'};
	 	for(var fields in a)
		{	
			var src_count=document.getElementById('count_src').value;
			for(var i=1;i<=src_count;i++)
			{
				var c = document.getElementsByName(a[fields]+i);  
				
				for(var j = 0; j < c.length; j++)
				{
				
					if(c[j].value == "")  
					{  
						
						alert('Please enter '+fields+' field'+i);
						c[j].focus();
						return false;       
					}
				}
			}
	 	}*/
		
		if(document.getElementById('num_src_village').value>0)
		{
			var src_count=document.getElementById('count_src').value;
			for(var i=1;i<=src_count;i++)
			{
				if(document.getElementById('district_name'+i).value=="")
				{
					alert('Please enter district name field'+i);
					document.getElementById('district_name'+i).focus();
					return false;
				}
				if(document.getElementById('block_name'+i).value=="")
				{
					alert('Please enter block name field'+i);
					document.getElementById('block_name'+i).focus();
					return false;
				}
				if(document.getElementById('panchayat_name'+i).value=="")
				{
					alert('Please enter gram panchayat name field'+i);
					document.getElementById('panchayat_name'+i).focus();
					return false;
				}
				if(document.getElementById('village_name'+i).value=="")
				{
					alert('Please enter village name field'+i);
					document.getElementById('village_name'+i).focus();
					return false;
				}
				
			}
			
			
		}

	
	if(document.getElementById('total_quant').value=="")
	{
		alert('Please enter total quantity of water produced at source field');
		document.getElementById('total_quant').focus();
		return false;
	}
	if(document.getElementById('investment').value=="")
	{
		alert('Please enter initial investment field. If no data write NA');
		document.getElementById('investment').focus();
		return false;
	}

var a={'district':'district2','block':'block2','gram panchayat':'panchayat2','village':'village2'};
	 	for(var fields in a)
		{	
			var c = document.getElementsByName(a[fields]);  
          	for(var j = 0; j < c.length; j++)
         	{
		 	
		 		if(c[j].value == 0)  
         		{  
            		alert('Please select '+fields+' name');
					c[j].focus();
					return false;       
         		}
		 	}
	 	}
		
		var hab_count=document.getElementById('habcount').value;
		var a=0;
		for(var i=1; i<=hab_count; i++)
		{
			var arr=document.getElementsByName('status_a_na'+i);
			//alert(arr[0].value);
			//alert(arr[1].value);
			if(arr[0].checked)
			{
				if(document.getElementById('quant_boundary'+i).value=="")
				{
					alert('Please enter quantity of water received at village boundary'+i);
					document.getElementById('quant_boundary'+i).focus();
					return false;
				}
			}
			a+=Number(document.getElementById('quant_boundary'+i).value);
		}
		
		//alert(a);
		if(Number(document.getElementById('total_quant').value) < Number(a))
		{
			alert('Total quantity of water produced at source not less than total quantity of water received at village boundary');
			document.getElementById('total_quant').focus();
			return false;
		}
		
		if(document.getElementById('num_unhabit').value > 0)
		{
			var num_unhabit = document.getElementById('num_unhabit').value;
			for(var i=1; i<=num_unhabit; i++)
			{
				if(document.getElementById('un_habit_ufw'+i).value=="")
				{
					alert('Please enter unlisted habitation name'+i);
					document.getElementById('un_habit_ufw'+i).focus();
					return false;
				}
			}
			
			
		}



}

function ufw4()
{
		var a={'status of reservoirs':'status_reserv'};
	 	for(var fields in a)
		{	
			var st_count=document.getElementById('count_st_res').value;
			for(var i=1;i<=st_count;i++)
			{
				var c = document.getElementsByName(a[fields]+i);  
				for(var j = 0; j < c.length; j++)
				{
				
					if(c[j].value == 0)  
					{  
						alert('Please select '+fields+' field'+i);
						c[j].focus();
						return false;       
					}
				}
			}
	 	}
			
	
}

function ufw5()
{
	var a={'electricity cost':'elec_cost','man power cost':'man_cost','chemicals cost':'chemical_cost','maintenance cost':'maintenance_cost'};
	 	for(var fields in a)
		{	
			var c = document.getElementsByName(a[fields]);  
          	for(var j = 0; j < c.length; j++)
         	{
		 	
		 		if(c[j].value == "")  
         		{  
            		alert('Please enter '+fields+' field');
					c[j].focus();
					return false;       
         		}
		 	}
	 	}
		if(document.getElementById('ind_map').value=="")
		{
			alert('Please upload index map');
			document.getElementById('ind_map').focus();
			return false;
		}
		
			var fup = document.getElementById('ind_map');
			var fileName = fup.value;
			var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
			if(ext == "pdf" || ext == "PDF")
			{
			}
			else
			{
				alert("Upload PDF file only");
				fup.focus();
				return false;
			}
			
			if(document.getElementById('num_photo').value > 0)
				{
					var count_photo=document.getElementById('num_photo').value;
					//alert(count_photo);
					for(var i=1; i<=count_photo; i++)
					{
						if(document.getElementById('photo_file'+i).value=="")
						{
							alert('Please upload photo'+i);
							document.getElementById('photo_file'+i).focus();
							return false;
						}
						
							var fup1 = document.getElementById('photo_file'+i);
							var fileName1 = fup1.value;
							//alert(fileName);
							var ext1 = fileName1.substring(fileName1.lastIndexOf('.') + 1);
							if(ext1 == "pdf" || ext1 == "PDF")
							{
								//return true;
							} 
							else
							{
								alert("Upload PDF file only");
								fup1.focus();
								return false;
							}		
						
						
						
						
					}
					
					
				}
}

function setReadOnlyufw_1(valobj,obj)
{
		document.getElementById('quant_boundary'+obj).disabled=true;
		document.getElementById('quant_boundary'+obj).value="";
		document.getElementById('status_a_na'+obj).value="Not Applicable";
		
}
function setEnableufw_1(valobj,obj)
{
	document.getElementById('quant_boundary'+obj).disabled=false;
	document.getElementById('quant_boundary'+obj).focus();
	document.getElementById('status_a_na'+obj).value="Applicable";
}

function setReadOnlyufw(valobj,obj)
{
		document.getElementById('gw_depth'+obj).disabled=true;
		document.getElementById('gw_level'+obj).disabled=true;
		document.getElementById('ph'+obj).disabled=true;
		document.getElementById('tds'+obj).disabled=true;
		document.getElementById('fl'+obj).disabled=true;
		document.getElementById('no'+obj).disabled=true;
		document.getElementById('cl'+obj).disabled=true;
		document.getElementById('num_pump'+obj).disabled=true;
		document.getElementById('src_status'+obj).value="NF"; 
		document.getElementById('gw_depth'+obj).value="";
		document.getElementById('gw_level'+obj).value="";
		document.getElementById('ph'+obj).value="";
		document.getElementById('tds'+obj).value="";
		document.getElementById('fl'+obj).value="";
		document.getElementById('no'+obj).value="";
		document.getElementById('cl'+obj).value="";
		document.getElementById('num_pump'+obj).value="";
		document.getElementById('pump_detail'+obj).style.display = "none";		
}
function setEnableufw(valobj,obj)
{
		
		document.getElementById('gw_depth'+obj).disabled=false;
		document.getElementById('gw_level'+obj).disabled=false;
		document.getElementById('ph'+obj).disabled=false;
		document.getElementById('tds'+obj).disabled=false;
		document.getElementById('fl'+obj).disabled=false;
		document.getElementById('no'+obj).disabled=false;
		document.getElementById('cl'+obj).disabled=false;
		document.getElementById('num_pump'+obj).disabled=false;
		document.getElementById('src_status'+obj).value="F";
		if(Number(document.getElementById('num_pump'+obj).value)>0)
		{
		document.getElementById('pump_detail'+obj).style.display = "block";
		}
	
}

function setReadOnlyufwdrop(valobj,obj,ob)
{
		document.getElementById('pump_cap_cons-'+obj+'-'+ob).disabled=true;
		document.getElementById('discharge_cons-'+obj+'-'+ob).disabled=true;
		document.getElementById('num_hrs-'+obj+'-'+ob).disabled=true;
		document.getElementById('current-'+obj+'-'+ob).disabled=true;
		document.getElementById('voltage-'+obj+'-'+ob).disabled=true;
		document.getElementById('power_factor-'+obj+'-'+ob).disabled=true;
		document.getElementById('kw_unit-'+obj+'-'+ob).disabled=true;
		document.getElementById('pump_cap_cons-'+obj+'-'+ob).value="";
		document.getElementById('discharge_cons-'+obj+'-'+ob).value="";
		document.getElementById('num_hrs-'+obj+'-'+ob).value="";
		document.getElementById('current-'+obj+'-'+ob).value="";
		document.getElementById('voltage-'+obj+'-'+ob).value="";
		document.getElementById('power_factor-'+obj+'-'+ob).value="";
		document.getElementById('kw_unit-'+obj+'-'+ob).value="";
		document.getElementById('status_pump-'+obj+'-'+ob).value="Def";
}

function setReadOnlyufwdrop1(valobj,obj,ob)
{
		document.getElementById('pump_cap_cons-'+obj+'-'+ob).disabled=true;
		document.getElementById('discharge_cons-'+obj+'-'+ob).disabled=true;
		document.getElementById('num_hrs-'+obj+'-'+ob).disabled=true;
		document.getElementById('current-'+obj+'-'+ob).disabled=true;
		document.getElementById('voltage-'+obj+'-'+ob).disabled=true;
		document.getElementById('power_factor-'+obj+'-'+ob).disabled=true;
		document.getElementById('kw_unit-'+obj+'-'+ob).disabled=true;
		document.getElementById('pump_cap_cons-'+obj+'-'+ob).value="";
		document.getElementById('discharge_cons-'+obj+'-'+ob).value="";
		document.getElementById('num_hrs-'+obj+'-'+ob).value="";
		document.getElementById('current-'+obj+'-'+ob).value="";
		document.getElementById('voltage-'+obj+'-'+ob).value="";
		document.getElementById('power_factor-'+obj+'-'+ob).value="";
		document.getElementById('kw_unit-'+obj+'-'+ob).value="";
		document.getElementById('status_pump-'+obj+'-'+ob).value="Sb";
}

function setEnableufwdrop(valobj,obj,ob)
{
		document.getElementById('pump_cap_cons-'+obj+'-'+ob).disabled=false;
		document.getElementById('discharge_cons-'+obj+'-'+ob).disabled=false;
		document.getElementById('num_hrs-'+obj+'-'+ob).disabled=false;
		document.getElementById('current-'+obj+'-'+ob).disabled=false;
		document.getElementById('voltage-'+obj+'-'+ob).disabled=false;
		document.getElementById('power_factor-'+obj+'-'+ob).disabled=false;
		document.getElementById('kw_unit-'+obj+'-'+ob).disabled=false;
		document.getElementById('status_pump-'+obj+'-'+ob).value="Op";
}

function ufw3()
{
	var count_pump=document.getElementById('pump_count').value;
	//alert(count_pump);
	for(var i=1;i<=count_pump;i++)
	{
		if(document.getElementById('elevation'+i).value=="")
		{
			alert('Please enter value in Elevation field'+i);
			document.getElementById('elevation'+i).focus();
			return false;
		}
		if(document.getElementById('north'+i).value=="")
		{
			alert('Please enter value in North field'+i);
			document.getElementById('north'+i).focus();
			return false;
		}
		if(document.getElementById('east'+i).value=="")
		{
			alert('Please enter value in East field'+i);
			document.getElementById('east'+i).focus();
			return false;
		}
		if(document.getElementById('src_status'+i).value=="F")
		{
			if(document.getElementById('gw_depth'+i).value=="")
			{
				alert('Please enter depth of GW field'+i);
				document.getElementById('gw_depth'+i).focus();
				return false;
			}
			if(document.getElementById('gw_level'+i).value=="")
			{
				alert('Please enter GW level fluctuation field'+i);
				document.getElementById('gw_level'+i).focus();
				return false;
			}
			if(document.getElementById('ph'+i).value=="")
			{
				alert('Please enter source water pH field'+i);
				document.getElementById('ph'+i).focus();
				return false;
			}
			if(document.getElementById('tds'+i).value=="")
			{
				alert('Please enter source water TDS field'+i);
				document.getElementById('tds'+i).focus();
				return false;
			}
			if(document.getElementById('fl'+i).value=="")
			{
				alert('Please enter source water fluoride field'+i);
				document.getElementById('fl'+i).focus();
				return false;
			}
			if(document.getElementById('no'+i).value=="")
			{
				alert('Please enter source water nitrate field'+i);
				document.getElementById('no'+i).focus();
				return false;
			}
			if(document.getElementById('cl'+i).value=="")
			{
				alert('Please enter source water chloride field'+i);
				document.getElementById('cl'+i).focus();
				return false;
			}
			if(document.getElementById('num_pump'+i).value=="")
			{
				alert('Please enter no. of pump field'+i);
				document.getElementById('num_pump'+i).focus();
				return false;
			}
			
			if(document.getElementById('num_pump'+i).value>0)
			{
				var count_pump1=document.getElementById('num_pump'+i).value;
				//alert(count_pump1);
				for(var j=1;j<=count_pump1;j++)
				{
					if(document.getElementById('type_pump-'+j+'-'+i).value==0)
					{
						alert('Please select type of pump-'+j+'-'+i);
						document.getElementById('type_pump-'+j+'-'+i).focus();
						return false;
					}
					if(document.getElementById('pump_cap-'+j+'-'+i).value=="")
					{
						alert('Please enter pump capacity field-'+j+'-'+i);
						document.getElementById('pump_cap-'+j+'-'+i).focus();
						return false;
					}
					if(document.getElementById('pump_discharge-'+j+'-'+i).value=="")
					{
						alert('Please enter pump discharge field-'+j+'-'+i);
						document.getElementById('pump_discharge-'+j+'-'+i).focus();
						return false;
					}
					if(document.getElementById('pump_head-'+j+'-'+i).value=="")
					{
						alert('Please enter head field-'+j+'-'+i);
						document.getElementById('pump_head-'+j+'-'+i).focus();
						return false;
					}
					if(document.getElementById('pump_depth-'+j+'-'+i).value=="")
					{
						alert('Please enter depth of pump field-'+j+'-'+i);
						document.getElementById('pump_depth-'+j+'-'+i).focus();
						return false;
					}
					if(document.getElementById('status_pump-'+j+'-'+i).value=="Op")
					{
						if(document.getElementById('pump_cap_cons-'+j+'-'+i).value=="")
						{
							alert('Please enter actual pump capacity field-'+j+'-'+i);
							document.getElementById('pump_cap_cons-'+j+'-'+i).focus();
							return false;
						}
						if(document.getElementById('discharge_cons-'+j+'-'+i).value=="")
						{
							alert('Please enter actual discharge field-'+j+'-'+i);
							document.getElementById('discharge_cons-'+j+'-'+i).focus();
							return false;
						}
						if(document.getElementById('num_hrs-'+j+'-'+i).value=="")
						{
							alert('Please enter no. of hrs. of operation field-'+j+'-'+i);
							document.getElementById('num_hrs-'+j+'-'+i).focus();
							return false;
						}
						if(document.getElementById('current-'+j+'-'+i).value=="")
						{
							alert('Please enter current field-'+j+'-'+i);
							document.getElementById('current-'+j+'-'+i).focus();
							return false;
						}
						if(document.getElementById('voltage-'+j+'-'+i).value=="")
						{
							alert('Please enter voltage field-'+j+'-'+i);
							document.getElementById('voltage-'+j+'-'+i).focus();
							return false;
						}
						if(document.getElementById('power_factor-'+j+'-'+i).value=="")
						{
							alert('Please enter power factor field-'+j+'-'+i);
							document.getElementById('power_factor-'+j+'-'+i).focus();
							return false;
						}
						if(document.getElementById('kw_unit-'+j+'-'+i).value=="")
						{
							alert('Please enter power cost field-'+j+'-'+i);
							document.getElementById('kw_unit-'+j+'-'+i).focus();
							return false;
						}
						
					}
					
					
					
					
				}
			
			}
		}
	}	
}

//=====================UFW=======UFW========UFW==============UFW======================================================

/*function Blank_del()
{
	var ques_val=document.getElementById('frm_name').value;
	var frm_val=document.getElementById('form_no').value;
	
	if(ques_val == 0)
	{
	  alert("Please Select Questionnaire");
	  document.f1.frm_name.focus();
	   return false;
	}
	if(frm_val == "")	
	{
		alert('Please Enter Form Numbers');
	    document.getElementById('form_no').focus();
		return false;
	}
}*/	

function numeric_del(field)
{
	var valid = "0123456789,"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++)
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no")
	{
		alert("Invalid entry! Only Numeric values separated by commas are Accepted!");
		//field.focus();
		field.value="";
		field.select();
		return false;
   }
}

function cnfrm()
{
	var ques_val=document.getElementById('frm_name').value;
	var frm_val=document.getElementById('form_no').value;
	if(ques_val == 0)
	{
	  alert("Please Select Questionnaire");
	  document.f1.frm_name.focus();
	   return false;
	}
	if(frm_val == "")	
	{
		alert('Please Enter Form Numbers');
	    document.getElementById('form_no').focus();
		return false;
	}
	if(frm_val != "")
	{
		//alert(frm_val);
		var arry = frm_val.split(','); 
		var cnt = arry.length;
		//alert(arry[0]);
		//var r=confirm('You are going to delete these Form Ids (' + for(var i=1; i<=cnt; i++) { arry[i] "\n" } + ') If you want to continue then click OK otherwise click Cancel');
		var r=confirm('You are going to delete these Form Ids (' + frm_val + ') If you want to continue then click OK otherwise click Cancel');
		if(r==false)
		{
			document.getElementById('form_no').focus();
			return false;
		}
	}
}